<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/swiper.min.js"></script>
    <link rel="stylesheet" href="css/swiper.min.css">
    <style>
        .swiper-container {
            width: 600px;
            height: 300px;
        }

        .swiper-slide img {
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="swiper-container">
        <div class="swiper-wrapper">
            <!-- <div class="swiper-slide">Slide 1</div>
            <div class="swiper-slide">Slide 2</div>
            <div class="swiper-slide">Slide 3</div> -->
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>

        <!-- 如果需要导航按钮 -->
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
    </div>
    <script>
        $.ajax({
            url: 'http://www.liulongbin.top:3005/api/getlunbo',
            type: 'get',
            success: function (data) {
                if (data.status != 0) return '请求失败'
                var str = ''
                data.message.forEach(function (item, index) {
                    str += `<div class="swiper-slide"><img src="${item.img}" alt=""></div>`;
                })
                $('.swiper-wrapper').html(str)
                var mySwiper = new Swiper('.swiper-container', {
                    loop: true, // 循环模式选项
                    // 如果需要前进后退按钮
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    }
                })
            }
        })

    </script>
</body>

</html>